package com.lost.octopus.es.processor.web.controller.base;

import com.sunsharing.share.boot.framework.annotation.ShareRest;
import com.lost.octopus.es.processor.entity.commom.AddMappingInfo;
import com.lost.octopus.es.processor.entity.commom.ServiceInvoker;
import com.lost.octopus.es.processor.service.common.CommonService;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 通用接口
 * @author zhangbh
 * @date 2025/4/14 10:31
 */
@Log4j2
@ShareRest
@RestController
@RequestMapping("common")
public class CommonApiController {

    @Resource
    private CommonService commonService;

    /**
     * 索引增加字段，并且调用初始化方法
     */
    @PostMapping(value = "addMappingAndInvokeInitService.do", name = "索引增加字段，并且调用初始化方法")
    public void addMappingAndInvokeInitService(@RequestBody AddMappingInfo info) {
        commonService.addMapping(info);
    }

    /**
     * 调用初始化方法
     */
    @PostMapping(value = "invokeInitService.do", name = "调用初始化方法")
    public void invokeInitService(@RequestBody ServiceInvoker info) {
        commonService.invokeInitService(info);
    }
}
